<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::group(['prefix' => 'user'], function () {
    Route::post('index','LoginController@index');
    Route::get('reLogin','LoginController@reLogin');
    Route::get('getOpenId/{jsCode}','LoginController@getOpenId');
});

Route::group(['namespace' => 'Home', 'prefix' => 'home', 'middleware' => 'Login'], function () {
    Route::group(['prefix' => 'release'], function(){
        //首页
        Route::get('index/{user_id}','IndexController@index');
        //详情
        Route::get('details/{id}/{type}','IndexController@details');
        //记录通知查看
        Route::post('record','IndexController@record');

        //获取模板
        Route::get('getTemplate/{type}','IndexController@getTemplate');

        //删除数据
        Route::delete('delRelease/{id}/{type}','IndexController@delRelease')
            ->where('id', '[0-9]+')
            ->where('type','notice|activity|vote|blessing');

        //添加通知
        Route::post('addNotice','ReleaseController@addNotice');
        // 修改通知
        Route::get('getOneNotice/{id}','ReleaseController@getOneNotice')->where('id', '[0-9]+');
        Route::post('updateNotice/{id}', 'ReleaseController@updateNotice')->where('id', '[0-9]+');

        //添加活动
        Route::post('addActivity','ReleaseController@addActivity');
        // 修改活动
        Route::get('getOneActivity/{id}','ReleaseController@getOneActivity')->where('id', '[0-9]+');
        Route::post('updateActivity/{id}', 'ReleaseController@updateActivity')->where('id', '[0-9]+');
        //活动报名
        Route::post('signUp/{id}', 'ReleaseController@signUp')->where('id', '[0-9]+');

        //添加投票
        Route::post('addVote','ReleaseController@addVote');
        // 修改投票
        Route::get('getOneVote/{id}','ReleaseController@getOneVote')->where('id', '[0-9]+');
        Route::post('updateVote/{id}', 'ReleaseController@updateVote')->where('id', '[0-9]+');
        //用户投票
        Route::post('userVote/{id}', 'ReleaseController@userVote')->where('id', '[0-9]+');

        //获取所有祝福语类型
        Route::get('getBlessingTextTypeList','BlessingController@getBlessingTextTypeList');
        //获取后台传的祝福语
        Route::get('getOneBlessingText/{id}','BlessingController@getOneBlessingText')->where('id','[0-9]+');
        Route::get('getOneBlessingTextByTypeId/{id}','BlessingController@getOneBlessingTextByTypeId')->where('id','[0-9]+');

        //添加祝福语
        Route::post('addBlessing','ReleaseController@addBlessing');
        // 修改祝福语
        Route::get('getOneBlessing/{id}','ReleaseController@getOneBlessing')->where('id', '[0-9]+');
        Route::post('updateBlessing/{id}', 'ReleaseController@updateBlessing')->where('id', '[0-9]+');
    });
});

Route::group(['namespace' => 'Admin', 'prefix' => 'admin'], function () {
    Route::group(['prefix' => 'index'], function(){
        //模板
        Route::post('template','IndexController@template');
        //删除
        Route::delete('delTemplate/{id}','IndexController@delTemplate');
    });

    //祝福语
    Route::group(['prefix' => 'blessing'], function(){
        //祝福语类型
        Route::post('addBlessingTextType','BlessingController@addBlessingTextType');
        Route::get('getBlessingTextTypeList','BlessingController@getBlessingTextTypeList');
        Route::get('getOneBlessingTextType/{id}','BlessingController@getOneBlessingTextType')->where('id', '[0-9]+');
        Route::post('updateBlessingTextType/{id}','BlessingController@updateBlessingTextType')->where('id', '[0-9]+');
        //祝福语
        Route::post('addBlessingText','BlessingController@addBlessingText');
        Route::get('getOneBlessingText/{id}','BlessingController@getOneBlessingText')->where('id', '[0-9]+');
        Route::get('getBlessingTextList','BlessingController@getBlessingTextList');
        Route::post('updateBlessingText/{id}','BlessingController@updateBlessingText')->where('id', '[0-9]+');

        //删除祝福语
        Route::delete('delBlessingText/{id}','BlessingController@delBlessingText')->where('id', '[0-9]+');
        //删除祝福语类型
        Route::delete('delBlessingTextType/{id}','BlessingController@delBlessingTextType')->where('id', '[0-9]+');
    });
});
